package com.xjscrm.console.chat.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author mingyang.chen create in 2024/3/11 17:56
 */
@Getter
@AllArgsConstructor
public enum MQMsgType {

    push_talk(4001, "推送聊天消息"),
    recall_success(4002, "推送撤回消息成功"),
    staff_offline(4003, "员工下线"),

    ;

    private final Integer code;
    private final String desc;

    public static MQMsgType getByCode(Integer code) {
        for (MQMsgType value : MQMsgType.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }

    public static String getAllDesc() {
        StringBuilder stringBuilder = new StringBuilder();
        for (MQMsgType value : MQMsgType.values()) {
            stringBuilder.append(value.getDesc()).append(":").append(value.getCode());
            stringBuilder.append(";");
        }
        return stringBuilder.toString();
    }
}
